<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>人员分配</title>
		<link rel="stylesheet" href="../style/bootstrap.min.css" />
		<script type="text/javascript" src="../scripts/jquery.js"></script>
		<script type="text/javascript" src="../scripts/bootstrap.min.js"></script>
		<script>
			function selectChange() {
				var chkSelectAll = document.getElementById("checkAll");
				var checked = chkSelectAll.checked;
				if(checked) {
					// select all products
					selectAllItem();
				} else {
					//unselect all products
					unSelectAll();
				}
			}

			//选择全部
			function selectAllItem() {
				var items = document.getElementsByName("tasid");
				for(var i = 0; i < items.length; i++) {
					items[i].checked = true;
				}
			}

			//取消全选
			function unSelectAll() {
				var items = document.getElementsByName("tasid");
				for(var i = 0; i < items.length; i++) {
					items[i].checked = false;
				}
			}
		</script>
		<script>
            function fpbutton() {
                var tasId = document.getElementsByName("tasid");
                var ids="";
                for (var i = 0 ;i<tasId.length;i++){
                    if (tasId[i].checked){
                        ids+=tasId[i].value+",";
					}
				}
                var itemId = $("#itemid").val();
                var userId =  $("#userid").val();
				$.ajax({
					type:"post",
					url:"/Projects/fpItemAudit",
					data:{"ids":ids,"itemId":itemId,"userId":userId},
					dataType:"json",
					success:function (taslist) {
					    var arr="<tr>" +
                            "<th><input type=\"checkbox\" id=\"checkAll\" onclick=\"selectChange()\"></th>" +
                            "<th>审计要点编号</th>" +
                            "<th>审计要点</th>" +
                            "<th>审计要点说明</th>" +
                            "<th>人员</th>" +
                            "</tr>";
					    for (var i=0;i<taslist.length;i++){
                            arr+="<tr>" +
                                "<td><input type=\"checkbox\" name=\"tasid\" value="+taslist[i].id+ "></td>" +
                                "<td>"+taslist[i].auditid+"</td>" +
                                "<td>"+taslist[i].auditname+"</td>" +
                                "<td>"+taslist[i].auditExplain+"</td>" +
                                "<td>"+taslist[i].person+"</td>" +
                                "</tr>"

						}

                        $("#updateTas").empty();
                        $("#updateTas").append(arr);
                    }
				})


            };


		</script>

	</head>

	<body>
		<div class="container">
			<!--
			<div class="row">
				<form action="" method="post">
					<h4 class="col-xs-offset-3 col-xs-9">
						项目批次时间：<input type="text">至<input type="text">
						<input class="btn-primary" type="button" value="查询" />
						<input class="btn-primary" type="reset" value="重置" />
					</h4>
				</form>
			</div>
			-->
			<form  action="" method="post">
				<div class="row">

					<h4 class="col-xs-offset-3 col-xs-9">
						项目:<select name="itemid" id="itemid">
						<option th:each="item:${items}"
								th:text="${item.name}" th:value="${item.id}">
						</option>
						</select>
						项目人员:<select name="userid" id="userid">
	+					<option th:each="us:${users}"
								th:text="${us.User.name}" th:value="${us.User.id}" >
						</option>
							</select>
					</h4>
					<h4 class="col-xs-offset-3 col-xs-4">
						审计要点编号查询:<input type="text" />
					</h4>
					<h4 class="col-xs-3 text-right">
						<input class="btn-primary" onclick="fpbutton()" type="button"  value="分配" />
						<input class="btn-primary" type="button" value="刷新" />
						<input type="checkbox" />锁定
					</h4>

				</div>
				<div style="height: 400px;">
					<table id="updateTas" class="table table-striped table-hover table-condensed">
						<tr>
							<th><input type="checkbox" id="checkAll" onclick="selectChange()"></th>
							<th>审计要点编号</th>
							<th>审计要点</th>
							<th>审计要点说明</th>
							<th>人员</th>
						</tr>
						<tr th:each="tas:${tasks}">
							<td><input type="checkbox" name="tasid" th:value="${tas.id}"></td>
							<td th:text="${tas.auditid}">审计要点编号</td>
							<td th:text="${tas.auditname}">审计要点</td>
							<td th:text="${tas.auditExplain}">审计要点说明</td>
							<td th:text="${tas.person}">人员</td>
						</tr>
					</table>
				</div>
			</form>
		</div>
	</body>

</html>